package function;

import java.util.Scanner;

public class Calculator {
	// 两个属性
	double num1;
	double num2;
	// 方法
	public void add () {
		System.out.println(num1 + num2);
	}
	public void sub () {
		System.out.println(num1 - num2);
	}
	public void div () {
		System.out.println(num1 * num2);
	}
	public void mul () {
		System.out.println(num1 / num2);
	}
	public static void main(String[] args) {
		//1.创建一个计算器对象
		Calculator c = new Calculator();
		//2.给属性赋值
		c.num1 = 10;
		c.num2 = 20;
		
		Scanner scan = new Scanner(System.in);
		String str = scan.next();
		//3.调用四个方法
		if (str.equals("+")) {
			c.add();
		}else if (str.equals("-")) {
			c.sub();
		}else if (str.equals("*")) {
			c.div();
		}else {
			c.mul();
		}
	}
}
